package models;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import play.data.validation.Required;
import play.db.jpa.Model;

@Entity
public class Channel extends Model {
	
	/* Variable Definitions */
	
	@Required
	private String name;
	
	@Required
	@ManyToOne
	@JoinColumn(name = "network_id")
	private Network network = null;
	
	/* End of Variable Definitions */
	
	
	/* Getter and Setter Methods */
	
	// -- name section --
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	// -- network section --
	
	public Network getNetwork() {
		return network;
	}
	
	public void setNetwork(Network network) {
		this.network = network;
	}
	
	/* End of Getter and Setter Methods */
	
	
	/* Other Methods */
	
	public String toString() {
		return name;
	}
	
	public static boolean isExist(String value) {
		return Show.find("byName", value) != null;
	}
	
	/* End of Other Methods */
	
}